//
//  RegistInfoView.m
//  YYPHSpeedJump
//
//  Created by sujiang on 15/12/18.
//  Copyright © 2015年 sujiang. All rights reserved.
//

#import "RegistInfoView.h"

@interface RegistInfoView ()<UITextFieldDelegate>


@property (nonatomic, strong) NSString *placeHolder;

@end

@implementation RegistInfoView

- (instancetype)initWithFrame:(CGRect)frame placeHolder:(NSString *)placeHolder
{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat height = frame.size.height;
        CGFloat width = frame.size.width;
        
        self.textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 3.5, width - 100, height)];
        self.textField.placeholder = placeHolder;
        // self.textField.font = [UIFont systemFontOfSize:12];
        self.textField.returnKeyType = UIReturnKeyDone;
        [self.textField setValue:kColors(131, 131, 131, 1) forKeyPath:@"_placeholderLabel.textColor"];
        [self.textField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
        [self addSubview:self.textField];
        self.textField.delegate = self;
        
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    self.placeHolder = textField.placeholder;
    textField.placeholder = nil;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if ([textField.text isEqualToString:@""]) {
        textField.placeholder = self.placeHolder;
    }
}



@end
